package com.gq.tab.scr;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.gq.nuhoangaicap.R;
import com.gq.utils.CustomViewPager;
import com.gq.utils.ImageViewPager;
import com.rtst.widget.tab.SwipeyTabs;

public class ImageDetailSrc extends Fragment {
	
	private ViewGroup viewGroup;
	private ImageViewPager imageViewPager;
	private String url;
	private CustomViewPager mViewPager;
	private SwipeyTabs mTabs;
	
	public ImageDetailSrc() {
	}
	
	public ImageDetailSrc(String url, CustomViewPager viewPager, SwipeyTabs sTabs) {
		this.url = url;
		this.mViewPager = viewPager;
		this.mTabs = sTabs;
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		if (viewGroup == null) {
			viewGroup = (ViewGroup) inflater.inflate(R.layout.image_detail, container, false);
			imageViewPager = (ImageViewPager)viewGroup.findViewById(R.id.image_view_pager);
			imageViewPager.init(url, mViewPager, mTabs);
		} else {
			((ViewGroup) viewGroup.getParent()).removeView(viewGroup);
		}
		return viewGroup;
	}
	
	public void dispose() {
		if (imageViewPager != null) imageViewPager.dispose();
	}
	
	public ImageViewPager getImageViewPager() {
		return imageViewPager;
	}
}
